<?php if (!defined("_ECRIRE_INC_VERSION")) return; if (class_exists('Ecatalogue')) return;
/**
 * EcataloguE
 *
 * @author     Aleksey Yaroshchuk (aleksey.yaroshchuk@gmail.com)
 * @license    GNU/GPL
 * @package    plugins
 * @subpackage ecatalogue
 * @copyright  (c) Aleksey Yaroshchuk 2011-2012
 * @link       http://www.spip-contrib.net/EcataloguE
 */

/**
 *  Ecatalogue main class
 *  All common elements are located here  
 *
 *  @author Aleksey Yaroshchuk (aleksey.yaroshchuk@gmail.com) 
 */ 
class Ecatalogue {   
    
    public function __construct() {
    }
    
/**
 *  Checks whether given rubrique is EcataloguE products rubrique
 *
 * @param int $id_rubrique ID rubrique
 * @return bool
**/
public function IsEcatalogueRubrique($id_rubrique) { 
	static $rubs = array();
	static $rubs_catalogue = false;

	// deja trouve
	if (isset($rubs[$id_rubrique])) {
		return $rubs[$id_rubrique];
	}

	// init
	if ($rubs_catalogue === false) {
		$r = lire_config('ecatalogue/branches');
		include_spip('spip_bonux_fonctions');
		$rubs_catalogue = picker_selected($r, 'rubrique'); // fn de spip bonux
	}

	// trouve
	if (in_array($id_rubrique, $rubs_catalogue)) {
		$rubs[$id_rubrique] = true;
		return true;
	}

	// rechercher dans la parente
	if ($id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique='.$id_rubrique)) {
		 $rubs[$id_rubrique] = $this->IsEcatalogueRubrique($id_parent);
		 return $rubs[$id_rubrique];
	}

	// perdu :)
	return false;
}
     
} 
?>